package cn.licoy.wdog.core.service.hospital.impl;

import cn.licoy.wdog.common.bean.ResponseCode;
import cn.licoy.wdog.common.exception.RequestException;
import cn.licoy.wdog.core.dto.hospitalUser.RegionDto;
import cn.licoy.wdog.core.entity.hospital.Region;
import cn.licoy.wdog.core.entity.hospital.Smscode;
import cn.licoy.wdog.core.mapper.hospital.RegionMapper;
import cn.licoy.wdog.core.mapper.hospital.SmscodeMapper;
import cn.licoy.wdog.core.service.hospital.RegionService;
import cn.licoy.wdog.core.service.hospital.SmscodeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author Sunne
 * Create time 2018/6/22 16:15
 * @return null
 **/
@Service
@Transactional
public class RegionServiceImpl extends ServiceImpl<RegionMapper,Region> implements RegionService {
    @Override
    public void add(RegionDto regionDto) {
        if (regionDto.getName()==null||"".equals(regionDto.getName())){
            throw new RequestException(ResponseCode.FAIL);
        }
        try {
        Region region = new Region();
        region.setName(regionDto.getName());
        region.setCreateDate(new Date());
        region.setRemake("1");
        this.insert(region);
        } catch (Exception e){
            throw RequestException.fail("添加地区失败",e);
        }
    }
}
